package com.tim.proxy;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PerformanceMonitoring {
	private static final Log log = LogFactory
			.getLog(PerformanceMonitoring.class);

	private static ThreadLocal<MethodPerformance> performanceRecord = new ThreadLocal<MethodPerformance>();// 当前线程中

	public static void begin(String method) {
		log.info("begin monitoring...");
		MethodPerformance mp = new MethodPerformance(method);
		performanceRecord.set(mp);
	}

	public static void end() {
		log.info("end monitoring...");
		MethodPerformance mp = performanceRecord.get();// 获取当前线程的对象实例
		mp.printPerformance();
	}
}
